package com.ln.jvm;

import java.nio.ByteBuffer;

/**
 * <pre>
 *  直接内存溢出
 *  -Xmx1g -XX:+PrintGCDetails
 * </pre>
 *
 * @Author zhangj
 * @Date 2022/7/7 23:33
 */
public class DirectMemoryOOM {

    public static void main(String[] args) {
        System.out.println(1);
        for (int i = 0; i < 1024; i++) {
            ByteBuffer.allocateDirect(1024 * 1024);
            System.out.println(i);
            System.gc();
        }
    }

}
